ffmpeg

Source(s)

  • get the original metadata from the video file
ffmpeg -i INPUT.mp4 -f ffmetadata ffmetadata.txt
;FFMETADATA1
major_brand=isom
minor_version=512
compatible_brands=isomiso2avc1mp41
encoder=Lavf60.16.100
  • add chapters to the metadata file
    • when using TIMEBASE=1/1000, the START and END values have to be in milliseconds, i.e. a timestamp of 2:32:13 would translate to 9133000
  • write a new video file using the edited metadata file
ffmpeg -i INPUT.mp4 -i ffmetadata.txt -map_metadata 1 -codec copy OUTPUT.mp4